package com.richapp.launcher.log;

import android.util.Log;

import com.jack.netty.log.ILogger;

import de.greenrobot.event.EventBus;

/**
 * Created by jack on 15/12/8.
 */
public class AndroidLogger implements ILogger {

    private boolean log2File = true;
    private boolean showDebug = false;

    @Override
    public void error(Class aClass, String s) {
        Log.e(aClass.getName(), s);

        if(log2File){
            EventBus.getDefault().post(new BusEventLog("error",aClass.getName(),s));
        }
    }

    @Override
    public void warn(Class aClass, String s) {
        Log.w(aClass.getName(), s);
        if(log2File){
            EventBus.getDefault().post(new BusEventLog("warn",aClass.getName(),s));
        }
    }

    @Override
    public void debug(Class aClass, String s) {
        Log.d(aClass.getName(), s);
        if(log2File && showDebug){
            EventBus.getDefault().post(new BusEventLog("debug",aClass.getName(),s));
        }
    }

    @Override
    public void info(Class aClass, String s) {
        Log.i(aClass.getName(), s);
        if(log2File){
            EventBus.getDefault().post(new BusEventLog("info",aClass.getName(),s));
        }
    }
}
